﻿Public Class ClsDSversionCompare
    'represents cover for dataset with version changes after comparison of two versions

#Region "Attributes"
#Region "Private attributes"
    Private MoDsChanges As AMod2.DsChanges = Nothing

    'colors
    Private MoColorAdded As Color = Color.ForestGreen
    Private MoColorRemoved As Color = Color.Red
    Private MoColorChanged As Color = Color.CornflowerBlue
#End Region
#End Region
#Region "Constructors"
#End Region
#Region "Properties"
#Region "Public attributes"
    Public ReadOnly Property DsChanges() As AMod2.DsChanges
        Get
            Return MoDsChanges
        End Get
    End Property
#End Region
#End Region
#Region "Functions"
    'compares two datasets
    Public Function Compare(ByVal IoFirstDS As AMod2.DsAModOneVersion, ByVal IoSecondDS As AMod2.DsAModOneVersion) As AMod2.DsChanges
        Try
            MoDsChanges = AMod2.ChangeChecker.CompareTwoVersions(IoFirstDS, IoSecondDS)
            Return MoDsChanges
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return Nothing
        End Try
    End Function
    'colors diagram objects
    Public Function ColorDiagram(ByVal IeSideOfCanvas As GeSideOfCanvas, ByVal IoDiagram As MindFusion.Diagramming.Diagram) As GeActionResult
        Try
            If MoDsChanges IsNot Nothing Then
                ColorUnits(IeSideOfCanvas, IoDiagram)
                ColorTables(IeSideOfCanvas, IoDiagram)
                ColorRelationshipLinks(IeSideOfCanvas, IoDiagram)
                ColorTableColumns(IeSideOfCanvas, IoDiagram)
                ColorNotes(IeSideOfCanvas, IoDiagram)
            Else
                MessageBox.Show("Verzie este neboli porovnane!", "Porovnanie verzii", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If
            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'colors units
    Private Function ColorUnits(ByVal IeSideOfCanvas As GeSideOfCanvas, ByVal IoDiagram As MindFusion.Diagramming.Diagram) As GeActionResult
        Try
            Select Case IeSideOfCanvas
                Case GeSideOfCanvas.kkLeft
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "32", "33"))

                    Dim LsOperation As String = ""
                    Dim LoMMContainerNode As ClsMMContainerNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "2"
                                'LoMMContainerNode = GetUnitFromDiagramByUnitName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                'ColorAsRemoved(LoMMContainerNode)

                                LoMMContainerNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.UnitId), IoDiagram)
                                ColorAsRemoved(LoMMContainerNode)
                            Case "3"
                                'Dim LsUnitName As String = ""
                                'If LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location2) = AMod2.DsAModOneVersion.TableSysnames.Units.Columns.UnitName Then
                                '    LsUnitName = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.OldValue)
                                'Else
                                '    LsUnitName = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1)
                                'End If
                                'LoMMContainerNode = GetUnitFromDiagramByUnitName(LsUnitName, IoDiagram)
                                'ColorAsChanged(LoMMContainerNode)

                                LoMMContainerNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.UnitId), IoDiagram)
                                ColorAsChanged(LoMMContainerNode)
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri formulari!", , )
                        End Select
                    Next
                Case GeSideOfCanvas.kkRight
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "31", "33"))

                    Dim LsOperation As String = ""
                    Dim LoMMContainerNode As ClsMMContainerNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "1"
                                'LoMMContainerNode = GetUnitFromDiagramByUnitName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                'ColorAsNew(LoMMContainerNode)

                                LoMMContainerNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.UnitId), IoDiagram)
                                ColorAsNew(LoMMContainerNode)
                            Case "3"
                                'LoMMContainerNode = GetUnitFromDiagramByUnitName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                'ColorAsChanged(LoMMContainerNode)

                                LoMMContainerNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.UnitId), IoDiagram)
                                ColorAsChanged(LoMMContainerNode)
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri formulari!", , )
                        End Select
                    Next
            End Select

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'colors tables
    Private Function ColorTables(ByVal IeSideOfCanvas As GeSideOfCanvas, ByVal IoDiagram As MindFusion.Diagramming.Diagram) As GeActionResult
        Try
            Select Case IeSideOfCanvas
                Case GeSideOfCanvas.kkLeft
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "12", "13"))

                    Dim LsOperation As String = ""
                    Dim LoMMTableNode As ClsMMTableNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "2"
                                'LoMMTableNode = GetTableFromDiagramByTableName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                'ColorAsRemoved(LoMMTableNode)

                                LoMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                ColorAsRemoved(LoMMTableNode)
                            Case "3"
                                'LoMMTableNode = GetTableFromDiagramByTableName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                'ColorAsChanged(LoMMTableNode)

                                LoMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                ColorAsChanged(LoMMTableNode)
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri triede!", , )
                        End Select
                    Next
                Case GeSideOfCanvas.kkRight
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "11", "13"))

                    Dim LsOperation As String = ""
                    Dim LoMMTableNode As ClsMMTableNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "1"
                                'LoMMTableNode = GetTableFromDiagramByTableName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                'ColorAsNew(LoMMTableNode)

                                LoMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                ColorAsNew(LoMMTableNode)
                            Case "3"
                                'LoMMTableNode = GetTableFromDiagramByTableName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                'ColorAsChanged(LoMMTableNode)

                                LoMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                ColorAsChanged(LoMMTableNode)
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri triede!", , )
                        End Select
                    Next
            End Select
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'colors table columns
    Private Function ColorTableColumns(ByVal IeSideOfCanvas As GeSideOfCanvas, ByVal IoDiagram As MindFusion.Diagramming.Diagram) As GeActionResult
        Try
            Select Case IeSideOfCanvas
                Case GeSideOfCanvas.kkLeft
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "22", "23"))

                    Dim LsOperation As String = ""
                    Dim LoMMTableNode As ClsMMTableNode = Nothing
                    Dim LsTableColumnName As String = ""
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "2"
                                'LoMMTableNode = GetTableFromDiagramByTableName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                LoMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                Dim LiRowIndex As Integer = LoMMTableNode.MMGetRowIndexByColumnID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.ColumnId))
                                LoMMTableNode.MMSetRowColor(LiRowIndex, New MindFusion.Drawing.SolidBrush(MoColorRemoved))
                            Case "3"
                                'LoMMTableNode = GetTableFromDiagramByTableName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                LoMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                Dim LiRowIndex As Integer = LoMMTableNode.MMGetRowIndexByColumnID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.ColumnId))
                                LoMMTableNode.MMSetRowColor(LiRowIndex, New MindFusion.Drawing.SolidBrush(MoColorChanged))

                                'add changed columns to collection of this table row. Collection is tag of the first cell (index 0)
                                Dim LoTableCell As MindFusion.Diagramming.TableNode.Cell = LoMMTableNode(0, LiRowIndex)
                                If LoTableCell.Tag IsNot Nothing Then
                                    Dim LoChangedColumns As Collection = CType(LoTableCell.Tag, Collection)
                                    LoChangedColumns.Add(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3), LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3))
                                Else
                                    Dim LoChangedColumns = New Collection
                                    LoChangedColumns.Add(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3), LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3))
                                    LoTableCell.Tag = LoChangedColumns
                                End If
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri polozke triedy!", , )
                        End Select
                    Next
                Case GeSideOfCanvas.kkRight
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "21", "23"))

                    Dim LsOperation As String = ""
                    Dim LoMMTableNode As ClsMMTableNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "1"
                                'LoMMTableNode = GetTableFromDiagramByTableName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                LoMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                Dim LiRowIndex As Integer = LoMMTableNode.MMGetRowIndexByColumnID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.ColumnId))
                                LoMMTableNode.MMSetRowColor(LiRowIndex, New MindFusion.Drawing.SolidBrush(MoColorAdded))
                            Case "3"
                                'LoMMTableNode = GetTableFromDiagramByTableName(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location1), IoDiagram)
                                LoMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                Dim LiRowIndex As Integer = LoMMTableNode.MMGetRowIndexByColumnID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.ColumnId))
                                LoMMTableNode.MMSetRowColor(LiRowIndex, New MindFusion.Drawing.SolidBrush(MoColorChanged))

                                'add changed columns to collection of this table row. Collection is tag of the first cell (index 0)
                                Dim LoTableCell As MindFusion.Diagramming.TableNode.Cell = LoMMTableNode(0, LiRowIndex)
                                If LoTableCell.Tag IsNot Nothing Then
                                    Dim LoChangedColumns As Collection = CType(LoTableCell.Tag, Collection)
                                    LoChangedColumns.Add(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3), LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3))
                                Else
                                    Dim LoChangedColumns = New Collection
                                    LoChangedColumns.Add(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3), LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3))
                                    LoTableCell.Tag = LoChangedColumns
                                End If
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri polozke triedy!", , )
                        End Select
                    Next
            End Select
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'colors relationship link
    Private Function ColorRelationshipLinks(ByVal IeSideOfCanvas As GeSideOfCanvas, ByVal IoDiagram As MindFusion.Diagramming.Diagram) As GeActionResult
        Try
            Select Case IeSideOfCanvas
                Case GeSideOfCanvas.kkLeft
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "43"))

                    Dim LsOperation As String = ""
                    Dim LoMMLinkNode As ClsMMLinkNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "1"
                                'do nothing
                            Case "3"
                                If LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3) = KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.ParentTable Then
                                    'skip new added relationship
                                    If LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.OldValue) <> "" Then
                                        Dim LoMMTableNode As ClsMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                        LoMMLinkNode = LoMMTableNode.IncomingLinks(0)
                                        'relationship was removed
                                        If LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.NewValue) = "" Then
                                            ColorAsRemoved(LoMMLinkNode)
                                        Else
                                            'relationship was changed
                                            ColorAsChanged(LoMMLinkNode)
                                        End If
                                    End If
                                End If
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri vztahu tabulky!", , )
                        End Select
                    Next
                Case GeSideOfCanvas.kkRight
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "41", "43"))

                    Dim LsOperation As String = ""
                    Dim LoMMLinkNode As ClsMMLinkNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "1"
                                Dim LoMMTableNode As ClsMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                LoMMLinkNode = LoMMTableNode.IncomingLinks(0)
                                ColorAsNew(LoMMLinkNode)
                            Case "3"
                                If LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Location3) = KrosLib.Editors.xModDataSet.TableSysnames.Hierarchy.Columns.ParentTable Then
                                    If LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.OldValue) = "" Then
                                        'relationship was added
                                        Dim LoMMTableNode As ClsMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                        LoMMLinkNode = LoMMTableNode.IncomingLinks(0)
                                        ColorAsNew(LoMMLinkNode)
                                    Else
                                        If LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.NewValue) <> "" Then
                                            'relationship was changed
                                            Dim LoMMTableNode As ClsMMTableNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.TableId), IoDiagram)
                                            LoMMLinkNode = LoMMTableNode.IncomingLinks(0)
                                            ColorAsChanged(LoMMLinkNode)
                                        End If
                                    End If
                                End If
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri vztahu tabulky!", , )
                        End Select
                    Next
            End Select
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'colors notes
    Private Function ColorNotes(ByVal IeSideOfCanvas As GeSideOfCanvas, ByVal IoDiagram As MindFusion.Diagramming.Diagram) As GeActionResult
        Try
            Select Case IeSideOfCanvas
                Case GeSideOfCanvas.kkLeft
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "52", "53"))

                    Dim LsOperation As String = ""
                    Dim LoMMNotNode As ClsMMNoteNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "2"
                                LoMMNotNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.NoteId), IoDiagram)
                                ColorAsRemoved(LoMMNotNode)
                            Case "3"
                                LoMMNotNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.NoteId), IoDiagram)
                                ColorAsChanged(LoMMNotNode)
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri poznamke!", , )
                        End Select
                    Next
                Case GeSideOfCanvas.kkRight
                    Dim LoRows As DataRow() = MoDsChanges.MainTable.Select(String.Format("{0}='{1}' or {0}='{2}'", AMod2.DsChanges.TableSysnames.Main.Columns.Operation, "51", "53"))

                    Dim LsOperation As String = ""
                    Dim LoMMNotNode As ClsMMNoteNode = Nothing
                    For Each LoRow As DataRow In LoRows
                        LsOperation = LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.Operation).ToString.Substring(1, 1)
                        Select Case LsOperation
                            Case "1"
                                LoMMNotNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.NoteId), IoDiagram)
                                ColorAsNew(LoMMNotNode)
                            Case "3"
                                LoMMNotNode = GetNodeFromDiagramByID(LoRow(AMod2.DsChanges.TableSysnames.Main.Columns.NoteId), IoDiagram)
                                ColorAsChanged(LoMMNotNode)
                            Case Else
                                LogEvent("Neznama operacia " & LsOperation & " pri poznamke!", , )
                        End Select
                    Next
            End Select

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'colors node as new
    Private Function ColorAsNew(ByRef OoNode As MindFusion.Diagramming.DiagramItem) As GeActionResult
        Try
            Select Case OoNode.GetType.Name
                Case "ClsMMTableNode", "ClsMMContainerNode", "ClsMMNoteNode"
                    OoNode.Brush = New MindFusion.Drawing.SolidBrush(MoColorAdded)
                Case "ClsMMLinkNode"
                    Dim LoMMLinkNode As ClsMMLinkNode = CType(OoNode, ClsMMLinkNode)
                    Dim LoPen As MindFusion.Drawing.Pen = MFPenVirginCreator(MoColorAdded, 0.1)
                    LoPen.DashStyle = Drawing2D.DashStyle.Solid

                    LoMMLinkNode.Pen = LoPen
            End Select

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'colors node as removed
    Private Function ColorAsRemoved(ByRef OoNode As MindFusion.Diagramming.DiagramItem) As GeActionResult
        Try
            Select Case OoNode.GetType.Name
                Case "ClsMMTableNode", "ClsMMContainerNode", "ClsMMNoteNode"
                    OoNode.Brush = New MindFusion.Drawing.SolidBrush(MoColorRemoved)
                Case "ClsMMLinkNode"
                    Dim LoMMLinkNode As ClsMMLinkNode = CType(OoNode, ClsMMLinkNode)
                    Dim LoPen As MindFusion.Drawing.Pen = MFPenVirginCreator(MoColorRemoved, 0.1)
                    LoPen.DashStyle = Drawing2D.DashStyle.Solid

                    LoMMLinkNode.Pen = LoPen
            End Select

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
    'colors node as changed
    Private Function ColorAsChanged(ByRef OoNode As MindFusion.Diagramming.DiagramItem) As GeActionResult
        Try
            Select Case OoNode.GetType.Name
                Case "ClsMMTableNode"
                    CType(OoNode, ClsMMTableNode).CaptionBackBrush = New MindFusion.Drawing.SolidBrush(MoColorChanged)
                Case "ClsMMContainerNode", "ClsMMNoteNode"
                    OoNode.Brush = New MindFusion.Drawing.SolidBrush(MoColorChanged)
                Case "ClsMMLinkNode"
                    Dim LoMMLinkNode As ClsMMLinkNode = CType(OoNode, ClsMMLinkNode)
                    Dim LoPen As MindFusion.Drawing.Pen = MFPenVirginCreator(MoColorChanged, 0.1)
                    LoPen.DashStyle = Drawing2D.DashStyle.Solid
                    LoMMLinkNode.Pen = LoPen
            End Select

            Return GeActionResult.kkOk
        Catch ex As Exception
            LogEventFromException(ex, , , )
            Return GeActionResult.kkError
        End Try
    End Function
#End Region

    'TableAdded = 11
    'TableRemoved = 12
    'TableChanged = 13

    'ColumnAdded = 21
    'ColumnRemoved = 22
    'ColumnChanged = 23

    'UnitAdded = 31
    'UnitRemoved = 32
    'UnitChanged = 33

    'HierarchyAdded = 41
    'HierarchyChanged = 43

End Class
